<?php

use yii\db\Migration;

/**
 * Handles the creation of table `menu`.
 */
class m170406_033919_create_menu_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('menu', [
            'id' => $this->primaryKey(),
            'name'=>$this->string(50)->notNull()->comment('菜单名称'),
            'route'=>$this->string(50)->notNull()->comment('菜单路由'),
            'parent_id'=>$this->smallInteger()->notNull()->defaultValue(0)->comment('上级菜单'),
            'level'=>$this->integer(2)->comment('菜单的级别'),
            'sort'=>$this->integer(2)->comment('排序'),
            'description'=>$this->text()->comment('菜单的描述'),
            'tree' => $this->integer(3)->defaultValue(0)->notNull()->comment('树的编号'),
            'lft' => $this->integer(5)->unsigned()->notNull()->defaultValue(0)->comment('左边界'),
            'rgt' => $this->integer(5)->unsigned()->notNull()->defaultValue(0)->comment('右边界'),
            'depth' => $this->integer(3)->unsigned()->defaultValue(0)->notNull()->comment('级别'),
        ]);
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('menu');
    }
}
